import React from 'react';
import ImageLazy from '../../commons/ImageLazy';
import NavLink from '../../commons/NavLink';
import { connect } from 'react-redux';
import {hashHistory } from 'react-router';
import {order_detail} from '../../../actions';
import {getHosImg,getDocImg,getServImg} from '../../../actions/ActionTypes';

let mydefault = React.createClass({
  componentDidMount:function(){
    const {dispatch} = this.props;
    dispatch(order_detail({union_sn:this.props.unionSN}))
  },
  render:function(){
    let orderDetailItem = this.props.orderDetailItem || [],
        _this = this;
        console.log(orderDetailItem);
    return(
      <div className="orderDetail">
        <div className="item_wrapper">
        {
          orderDetailItem.map(function(item,index){
            let imgSrc = getServImg(item.itemImage,'_200_200',item.hospitalId,item.itemId)
            if(item.unionSN == _this.props.unionSN){
              return(
                <div>
                  <div className="item">
                    <div className="wrapper clearfix">
                      <em className="checks"><var></var></em>
                      <h4>{item.itemName}·{item.itemClass}·{item.doctorName}{item.doctorTitle}</h4>
                      <div className="mid">
                        <em style={{"background-image":"url("+ imgSrc + ")"}}></em>
                        <div>
                          医院：{item.hospitalName}
                        </div>
                      </div>
                      <h5>预约金：¥ {item.itemPrice}</h5>
                      {/* <div className="num">×3</div> */}
                    </div>
                  </div>
                  <div className="serv_code box">
                    <em>服务码  {item.serviceCode.length==0?'此订单状态暂无':item.serviceCode}</em>
                    <small>(手术前将验证码交给医生进行验证)</small>
                  </div>
                  <div className="order_info border_t1">
                    <div className="border_b1">
                      <span>订单编号</span><span>{item.orderSN}</span>
                    </div>
                    <div className="border_b1">
                      <span>创建时间</span><span>{item.createTime}</span>
                    </div>
                    <div className="border_b1">
                      <span>付款时间</span><span>{item.paymentTime}</span>
                    </div>
                  </div>
                  <div className="status border_b1">
                    <div className="wrapper">
                      <div className="left"></div>
                      <div className="right">
                        <a href={"tel:" + item.doctorMobile} className="pays">联系医生</a>
                      </div>
                    </div>
                  </div>
                </div>
              )
            }
          })
        }

        </div>
      </div>
    )
  }
})

let mapStateToProps = (state,own)=>{
  console.log(own.params)
  return{
    orderDetailItem:state.user.order_detail,
    unionSN:own.params.unionSN
  }
}

export default connect(mapStateToProps)(mydefault);
